Skip to content

Add selector initial values#12142

Merged
balloob merged 3 commits intodevfrom
add-some-form-initial-data
Mar 28, 2022
Merged

Add selector initial values#12142
balloob merged 3 commits intodevfrom
add-some-form-initial-data

Conversation

@zsarnett
Copy link
Copy Markdown
Contributor

Breaking change

Proposed change

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (thank you!)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example configuration

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue or discussion:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

balloob
balloob previously approved these changes Mar 28, 2022
@zsarnett zsarnett enabled auto-merge (squash) March 28, 2022 15:41
@zsarnett zsarnett disabled auto-merge March 28, 2022 15:41
@zsarnett zsarnett enabled auto-merge (squash) March 28, 2022 15:41
data[field.name] = [0, 0, 0];
} else if ("color_temp" in selector) {
data[field.name] = selector.color_temp.min_mireds ?? 153;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make sure we notice it when we're adding new selectors.

Suggested change
}
} else {
throw new Error("Selector not supported in initial form data");
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We haven't added all of them. Device, Entity, area, etc. SHould we just do empty string?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

@zsarnett zsarnett disabled auto-merge March 28, 2022 15:42
@zsarnett zsarnett changed the title Add Some Selector Defaults Add Time and color initial values Mar 28, 2022
Comment on lines +39 to +43
if (selector.device.multiple) {
data[field.name] = [];
} else {
data[field.name] = "";
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slightly more readable

Suggested change
if (selector.device.multiple) {
data[field.name] = [];
} else {
data[field.name] = "";
}
data[field.name] = selector.device.multiple ? [] : "";

balloob
balloob previously approved these changes Mar 28, 2022
@zsarnett zsarnett changed the title Add Time and color initial values Add selector initial values Mar 28, 2022
@balloob balloob merged commit ca22ec6 into dev Mar 28, 2022
@balloob balloob deleted the add-some-form-initial-data branch March 28, 2022 17:39
@github-actions github-actions bot locked and limited conversation to collaborators Mar 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants